package chpt03;
import java.util.Arrays;
import java.util.Scanner;

abstract class Shape1 {
	final double PI = 3.14;
	abstract double getPerimeter();
	abstract double getArea();
		
}

public class Shape_Inherit{
	public static double sumAllArea(Shape1[] o){
		double sum=0;
		for(int i=0;i<o.length;i++){
			sum+=o[i].getArea();
		} 
		return sum;
	}
	
	public static double sumAllPerimeter(Shape1[] o){
		double sum=0;
		for(int i=0;i<o.length;i++){
			sum+=o[i].getPerimeter();
		} 
		return sum;
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()){
			int n=in.nextInt();
			Shape1[] shapes=new Shape1[n];
			for (int i = 0; i < shapes.length; i++) {
				String str=in.next();
				if(str.equals("rect")){
					shapes[i]=new Rectangle1(in.nextInt(),in.nextInt());
				}
				if(str.equals("cir")){
					shapes[i]=new Circle1(in.nextInt());
				}
				
			}
			
			System.out.println(sumAllPerimeter(shapes));
			System.out.println(sumAllArea(shapes));
			System.out.println(Arrays.toString(shapes));
			for (Shape1 e : shapes) {
				System.out.println(e.getClass()+","+e.getClass().getSuperclass());
			}
		}
		in.close();
	}
}

class Rectangle1 extends Shape1 {
	
	private int width = 0;
	private int length = 0;
	
    public int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public Rectangle1(int width,int length){
        this.length = length;
        this.width = width;
    }
    public double getPerimeter(){
    	return 2*(width+length);
    }
    public double getArea(){
        return width*length;
    }
	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
	
}

class Circle1 extends Shape1 {
	private int radius = 0;
	
	public double getRadius() {
		return radius;
	}
	public void setRadius(int radius) {
		this.radius = radius;
	}
	public Circle1(int radius){
        this.radius = radius;
    }
	 public double getPerimeter(){
	    	return 2*PI*radius;
	    }
    public double getArea(){
        return PI*radius*radius;
    }
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
    
}